#pragma once

#include "Drawable.h"
#include <string>
#include <fstream>
using namespace std;

// a piece is made up of 1-5 blocks, which shapes' are defined in shapes.txt
// noteworthy: shapes are defined internally by two dimensional square arrays of booleans 
//true means there is a block in that location, false means empty
class Piece: public Drawable
{
protected:
	Vec3D m_v3InitialPos;
	int m_iSize;
	bool** m_bppTempShape;	// a temporary grid to hold the new shape if it needs to be rotated
	bool ParseFileForShape(char* fileName);

public:
	bool m_bFirstPiece;
	bool m_bUpdatedShape;
	bool** m_bppShape;		// the shape of the piece, defined in a two dimensional boolean grid

	virtual bool Init(int type, int owner, Vec3D pos);
	void AllocateShape(bool** &shape, int size);
	void DeallocateShape(bool** &shape, int size);
	virtual void CreateWorldTransform(D3DXMATRIX &matWorld);
	virtual void Rotate(int direction);
	void Move(Direction dir);
	void MoveTo(float xPos, float zPos);
	void Return();
	int getSize() { return m_iSize; }

	Piece();
	Piece(Piece const & a_copy);

	~Piece();
};